Ideally, computer instructions are executed by hardware resources, which are very fast. However, there are some circumstances in which hardware execution of computer instructions is not possible. For example, a software program may include a new instruction that is intended for a new version of a hardware resource. An old version of the same hardware resource does not implement the new instruction. Therefore, when the old version of the hardware resource tries to execute the new instruction, an exception is taken. In such an event, a software exception handler is invoked to implement the new instruction in software. To support this type of compatibility, the software exception handler must be updated with drivers to emulate new instructions.
Another common circumstance in which hardware execution of a computer instruction is not possible is in connection with floating point operations. It is not uncommon for a floating point unit hardware designer to decide not to support obscure operations because they require so many hardware resources. Instead, the hardware designer may decide to support obscure operations in software. In such a case, the floating point unit throws an exception in response to a request for an obscure operation. The obscure operation is subsequently emulated in software.
Another instance in which hardware execution of a computer instruction is not possible is in virtualized environment. Virtualization refers to the creation of a virtual, rather than an actual, version of something, such as a hardware platform, operating system, a storage device or a network resource. For example, a computer that is running Microsoft® Windows® may host a virtual machine that looks like a computer with an Apple® operating system. Subsequently, Apple® compliant software can be executed on the virtual machine.
In hardware virtualization, the term host machine refers to the actual machine on which the virtualization takes place. The term guest machine refers to the virtual machine. The software or firmware that creates a virtual machine on the host machine is called a hypervisor.
When an instruction of a guest machine is received by the host machine, an exception is thrown. This results in a call to the hypervisor. The hypervisor looks up the instruction in memory and then executes a software implementation of the function associated with the instruction. Thus, the instruction fault initiates a software call to the hypervisor, which subsequently initiates a memory call to look up the instruction. This sequence of calls is relatively time consuming. Since there are many such calls to a virtual machine, host machine processing is substantially strained.
This problem of initiating a memory call to look up an unsupported instruction also occurs in the previously discussed examples of unsupported instructions processed by legacy hardware resources and unsupported instructions processed by a floating point unit. In each instance, the memory call consumes many processing cycles and therefore degrades system performance.
Accordingly, it would be desirable to provide improved techniques for initiating the processing of instructions that are not executed in hardware.